package it.ap.sa.core.utils;

import java.util.Locale;

import org.springframework.context.MessageSource;
import org.springframework.stereotype.Component;

@Component
public class LocaleUtilCtrl {

	public static String getMessage(String key, Locale locale) {
		MessageSource messageSource = (MessageSource) SpringContextProvider.getApplicationContext().getBean("webMessageSource");
		return messageSource.getMessage(key, new Object[] {}, locale);
	}

	public static Locale getLocale() {
	    Locale locale = new Locale(System.getProperty("user.language"), System.getProperty("user.country"));
	    
	    return locale;
	}
	
	public static String getMessage(String key, Object[] args, Locale locale){
		MessageSource messageSource = (MessageSource) SpringContextProvider.getApplicationContext().getBean("webMessageSource");
		return messageSource.getMessage(key, args, locale);
	}
}
